import axios from 'axios'
import qs from 'qs'

// const baseUrl='http://47.98.191.33/platform-admin-1.0.0';
const baseUrl='http://47.98.191.33:9180/platform-admin-1.0.0';

const Api={
    //获取图片验证码
    getcaptchaSrc(){
        return axios.post(baseUrl+'/captcha.jpg')
    },
    //登录
    login(username,password,captcha){
        return axios.post(baseUrl+'/sys/login',qs.stringify({username:username,password:password,captcha:captcha}))
    },
    //用户信息
    userInfo(){
        return axios.post(baseUrl+'/sys/user/info')
    },
    //退出登录
    loginOut(){
        return axios.get(baseUrl+'/logout')
    },
    //修改密码
    changePwd(password,newPassword){
        return axios.post(baseUrl+'/sys/user/password',qs.stringify({password:password,newPassword}))
    },
    //学校列表
    schoolList(page,limit,sidx,order){
        return axios.post(baseUrl+'/campus/list',qs.stringify({page:page,limit:limit,sidx:sidx,order:order}))
    },
    //所属类目
    belongs(){
        return axios.get(baseUrl+'/category/getAreaTree')
    },
    //发布列表、查询列表（同一接口）(param={ page:'', limit:'',sidx:'',order:'',addTime1:'',addTime2:this.searchTime[1], school:'', categoryID:''})
    releaseList(param){
        return axios.post(baseUrl+'/goods/list',qs.stringify(param))
    },
    //发布列表删除
    releaseDelete(id){
        // return axios.post(baseUrl+'/goods/delete',qs.stringify([id],{arrayFormat: 'brackets'}),{headers:{'Content-Type': 'application/json; charset=UTF-8'}})
        return axios.post(baseUrl+'/goods/delete',qs.stringify({ids:id}))
    },
    //发布总数
    releaseTotal(){
        return axios.post(baseUrl+'/goods/queryTotal')
    },
    //用户列表 param与发布列表大致相同
    userList(param){
        return axios.post(baseUrl+'/user/list',qs.stringify(param))
    },
    //三方服务 param与发布列表大致相同
    service(param){
        return axios.post(baseUrl+'/service/list',qs.stringify(param))
    }
}
export {Api,baseUrl}